home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 23
/
Amiga Format AFCD23 (Feb 1998, Issue 107).iso
/
-seriously_amiga-
/
shareware
/
programming
/
c
/
asyncio
/
src
/
closeasync.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-12-01
|
803b
|
49 lines
#include "async.h"
_LIBCALL LONG
CloseAsync( _REG( a0 ) AsyncFile *file )
{
LONG result;
if( file )
{
#ifdef ASIO_NOEXTERNALS
struct ExecBase *SysBase = file->af_SysBase;
struct DosLibrary *DOSBase = file->af_DOSBase;
#endif
result = AS_WaitPacket( file );
if( result >= 0 )
{
if( !file->af_ReadMode )
{
/* this will flush out any pending data in the write buffer */
if( file->af_BufferSize > file->af_BytesLeft )
{
result = Write(
file->af_File,
file->af_Buffers[ file->af_CurrentBuf ],
file->af_BufferSize - file->af_BytesLeft );
}
}
}
if( file->af_CloseFH )
{
Close( file->af_File );
}
FreeVec(file);
}
else
{
#ifndef ASIO_NOEXTERNALS
SetIoErr( ERROR_INVALID_LOCK );
#endif
result = -1;
}
return( result );
}